package com.czp.ssm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.czp.ssm.bean.Company;
import com.czp.ssm.bean.HotelOrder;
import com.czp.ssm.bean.Opera;
import com.czp.ssm.bean.PlaneOrder;
import com.czp.ssm.bean.TrainOrder;
import com.czp.ssm.service.HotelService;
import com.czp.ssm.service.OperaService;
import com.czp.ssm.service.PlaneService;
import com.czp.ssm.service.TrainService;


@Controller
@RequestMapping("/operaController")
public class OperaController {

	@Autowired
	private PlaneService planeService;
	@Autowired
	private OperaService operaService; 
	@Autowired
	private TrainService trainService;
	@Autowired
	private HotelService hotelService;
	
	/**
	 * 飞机票审核
	 * @return
	 */
	@RequestMapping("/planeOperaList")
	public ModelAndView planeOperaList() {
		String operaPersonId = "0009";//当前审批人
		List<PlaneOrder> planeOrders = operaService.findPlaneOrderByOperaPersonId(operaPersonId);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("planeOrders", planeOrders);
		modelAndView.setViewName("background/opera/planeOperaList");
		return modelAndView;
	}
	
	/**
	 * 飞机票审批通过
	 */
	@RequestMapping(value= {"/planeOperaPass/{id}"})
	public String planeOperaPass(@PathVariable String id) {
		int flag = planeService.updatePlaneOrderStatus(id,"1");
		return "forward:/operaController/planeOperaList";
	}
	
	
	/**
	 * 飞机票审核不通过
	 */
	@RequestMapping(value= {"/planeOperaDown/{id}"})
	public String planeOperaDown(@PathVariable String id) {
		int flag = planeService.updatePlaneOrderStatus(id,"2");
		return "forward:/operaController/planeOperaList";
	}
	
	
	/**
	 * 火车票审核
	 * @return
	 */
	@RequestMapping("/trainOperaList")
	public ModelAndView trainOperaList() {
		String operaPersonId = "0009";//当前审批人
		List<TrainOrder> trainOrders = trainService.findTrainOrderByOperaPersonId(operaPersonId);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("trainOrders", trainOrders);
		modelAndView.setViewName("background/opera/trainOperaList");
		return modelAndView;
	}
	
	/**
	 * 火车票审批通过
	 */
	@RequestMapping(value= {"/trainOperaPass/{id}"})
	public String trainOperaPass(@PathVariable String id) {
		int flag = trainService.updateTrainOrderStatus(id,"1");
		return "forward:/operaController/trainOperaList";
	}
	
	
	/**
	 * 火车票审核不通过
	 */
	@RequestMapping(value= {"/trainOperaDown/{id}"})
	public String trainOperaDown(@PathVariable String id) {
		int flag = trainService.updateTrainOrderStatus(id,"2");
		return "forward:/operaController/trainOperaList";
	}
	
	
	/**
	 * 酒店订单审核
	 * @return
	 */
	@RequestMapping("/hotelOperaList")
	public ModelAndView hotelOperaList() {
		String operaPersonId = "0009";//当前审批人
		List<HotelOrder> hotelOrders = hotelService.findHotelOrderByOperaPersonId(operaPersonId);
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("hotelOrders", hotelOrders);
		modelAndView.setViewName("background/opera/hotelOperaList");
		return modelAndView;
	}
	
	/**
	 * 火车票审批通过
	 */
	@RequestMapping(value= {"/hotelOperaPass/{id}"})
	public String hotelOperaPass(@PathVariable String id) {
		int flag = hotelService.updateHotelOrderStatus(id,"1");
		return "forward:/operaController/hotelOperaList";
	}
	
	
	/**
	 * 火车票审核不通过
	 */
	@RequestMapping(value= {"/hotelOperaDown/{id}"})
	public String hotelOperaDown(@PathVariable String id) {
		int flag = hotelService.updateHotelOrderStatus(id,"2");
		return "forward:/operaController/hotelOperaList";
	}
	
	
}
